var watchUserTable;
//var roleid = document
//.getElementById("roleid").value;
//if (roleid == "0") {
//	document.getElementById("actions").style.visibility = "hidden";// 隐藏
//}
function getwatchUserList() {
	if (typeof watchUserTable !== 'undefined') {
		watchUserTable.fnPageChange('first');
		return;
	}
	var i = 1;
	watchUserTable = $("#watchUserList")
			.DataTable(
					{
						"sAjaxSource" : _path + "/watchUseRobot/queryByPage",
						"fnServerParams" : function(aoData) {
							aoData.push({
								"name" : "userNickName",
								"value" : $("#userNickName").val()
							});
						},
						"sServerMethod" : "POST",
						"sAjaxDataProp" : "dataList",
						"fnCreatedRow" : function() {
							i++;
						},
						"fnPreDrawCallback" : function() {
							i = 1;
						},
						"aoColumns" : [
								{
									"sTitle" : "序号",
									"sWidth" : "2%",
									"mData" : function() {
										return i;
									}
								},
								{
									"sTitle" : "名字",
									"mData" : "userNickName",
									"sWidth" : "10%"
								},
								{
									"sTitle" : "国家",
									"mData" : "userCity",
									"sWidth" : "10%"
								},
								{
									"sTitle" : "性别",
									"mData" : "userSex",
									"sWidth" : "10%",
									"mRender" : function(data) {
										var status = '';
										switch (data) {
										case '1':
											status = '男性';
											break;
										case '2':
											status = '女性';
											break;
									
										default:
											status = '未知';
											break;
										}
										return status;
									}
								},
								{
									"sTitle" : "操作",
									"sWidth" : "10%",
									"mData" : function(data) {
//										var status = '<a href="'
//												+ _path
//												+ '/watchUser/edit/'
//												+ data.id
//												+ '" class="btn default btn-xs purple"><i class="fa fa-edit" title="编辑"></i></a>';
										var	status = '';
										
											status += '&nbsp;<a href="javascript:inquiry('
													+ data.id
													+ ');"  class="btn default btn-xs red"><i class="fa fa-trash-o" title="删除"></i></a>';
										
										return status;
									}
								} ]
					});
}
function inquiry(id) {

	layer.confirm('您确定要删除吗？', {
		btn : [ '确定', '取消' ]
	// 按钮
	}, function() {
		location.href = _path + "/watchUser/del/" + id;
	}, function() {

	});
}

//下拉列表选项操作
function advertising(id){
	var i=$("#select"+id).val();                          //获取选中的value的值
	var s=$("#select"+id).find("option:selected").text(); //获取选中文本域的值
	if(i=='3'){
		location.href = _path + "/communication/list/" + id;
	}else if(i=='4'){
		location.href = _path + "/advertising/list/" + id;
	}		
}

//对当前页面进行刷新
function Refresh(){
	location.reload();
}
//页面重定向跳转
function Refreshs(id){
	location.href = _path + "/relatedVideo/list/"+id;
}

